package com.demo.tankGame05;

/**
 * tank 的 父类，让子类坦克继承
 * @author gy
 * @date 2022/4/18
 */
public class Tank {
    private int x;
    private int y;
    /**
     * 控制坦克方向0:向上 1:向右 2:向下 3:向左
     */
    private int direct;
    /**
     * 控制坦克的速度 初始速度为1
     */
    private int speed = 1;

    boolean isLive = true;

    public Tank(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public Tank(int x, int y, int speed) {
        this.x = x;
        this.y = y;
        this.speed = speed;
    }

    public void moveUp(){
        y-= speed;
    }
    public void moveRight(){
        x+= speed;
    }
    public void moveDown(){
        y+= speed;
    }
    public void moveLeft(){
        x-= speed;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public int getDirect() {
        return direct;
    }

    public void setDirect(int direct) {
        this.direct = direct;
    }

    public int getSpeed() {
        return speed;
    }

    public void setSpeed(int speed) {
        this.speed = speed;
    }
}
